<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<script type="text/javascript" src="/oa/Public/js/jquery.js"></script>
<script type="text/javascript" src="/oa/Public/js/common.js"></script>
<link rel="stylesheet" type="text/css" href="/oa/Public/css/global.css" />
<link rel="stylesheet" type="text/css" href="/oa/Public/css/form.css" />
</head>
<body>
<div class="search">
<form action="/oa/index.php/Album/add" method="post" name="form1" id="form1" onsubmit="return checkform()">
<b>新建相册：</b><input type="text" name="name" >
<input type="submit" value="创建" title="创建新相册" class="submit">
</form>
</div>
<div class="list" >
	<?php if(is_array($list)): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><div class="album">
		<div class="image"><a href="javascript:;" onclick="view(<?php echo ($vo["id"]); ?>)"><img src="<?php echo ($vo["img"]); ?>" /></a></div>
		<div class="name" ><span ondblclick="edit(this,<?php echo ($vo["id"]); ?>)"><?php echo ($vo["name"]); ?></span><input type="hidden" name="id[]" value="<?php echo ($vo["id"]); ?>" /></div>
	</div><?php endforeach; endif; else: echo "" ;endif; ?>
</div>
</body>
<script type="text/javascript">
$('img').error(function() {
	$(this).attr("src", "/oa/Public/images/pic-error.png");
});
var url = "/oa/index.php/Album/";
function checkform(){
	var val = $("input[name='name']").val();
	if(val == ""){
		alert("相册名称不能为空");return false;
	}else if(val.indexOf(" ") >= 0){
		alert("相册名称不能有空格！");return false;
	}
}
function view(id){
	window.location= url+"view?id="+id;
}
function edit(msg,id){
	var text = $(msg).text();
	$(msg).html("<input type='text' name='album' value='"+text+"' size=18 />");
	$("input[name='album']").focus();
	$("input[name='album']").blur(function(){
		var name = $(this).val();
		if(name.indexOf(" ") >= 0 || name == ""){
			alert("相册名称不能为空且不能含有空格！");
			$("input[name='album']").focus();
			$("input[name='album']").select();
		}else{
			if(text == name){
				$(msg).html(text);
			}else{
				$.get( url+"edit?id="+id+"&name="+encodeURI(name), function(result){
					if(result != ''){alert(result);}
					$(msg).html(name);
				});
			}
		}
	});
}
</script>
</html>